﻿namespace Tszy.Unlimited.Base.Infrastructure.Logging;

/// <summary>
/// 日志记录器。
/// </summary>
public class TszyLogger : ILogger
{
    private static ILogger _logger = new SerilogLogger();

    /// <summary>
    ///
    /// </summary>
    public static ILogger Instance => _logger;

    /// <summary>
    /// 日志信息前缀。
    /// </summary>
    public static LoggerConfig Configs { get; private set; } = new LoggerConfig();

    /// <summary>
    ///
    /// </summary>
    /// <param name="logger"></param>
    public static void SetLogger(ILogger logger)
    {
        if (logger == null)
            return;

        _logger = logger;
    }

    /// <summary>
    ///
    /// </summary>
    /// <param name="message"></param>
    /// <param name="exception"></param>
    public void Error(string message, Exception? exception = null)
    {
        _logger.Error(message, exception);
    }

    /// <summary>
    ///
    /// </summary>
    /// <param name="message"></param>
    /// <param name="exception"></param>
    public void Fatal(string message, Exception? exception = null)
    {
        _logger.Fatal(message, exception);
    }

    /// <summary>
    ///
    /// </summary>
    /// <param name="message"></param>
    /// <param name="exception"></param>
    public void Debug(string message, Exception? exception = null)
    {
        _logger.Debug(message, exception);
    }

    /// <summary>
    ///
    /// </summary>
    /// <param name="message"></param>
    /// <param name="exception"></param>
    public void Warning(string message, Exception? exception = null)
    {
        _logger.Warning(message, exception);
    }

    /// <summary>
    ///
    /// </summary>
    /// <param name="message"></param>
    /// <param name="exception"></param>
    public void Information(string message, Exception? exception = null)
    {
        _logger.Information(message, exception);
    }
}
